package com.doupi.partner.constant;

/**
 * 商家来源
 * 
 * @author Alvin Wang
 * @version 1.0.0 @ 2017-04-17
 */
public enum BusinessSourceEnum {
	DOUPI("逗皮", Byte.valueOf("1")), DOUMI("逗米", Byte.valueOf("2"));

	private String name;
	private byte code;

	BusinessSourceEnum(String name, byte code) {
		this.name = name;
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public byte getCode() {
		return code;
	}

	/**
	 * 根据 code获取 {@link BusinessSourceEnum}
	 *
	 * @param code
	 *            code
	 * @return {@link BusinessSourceEnum}
	 */
	public static BusinessSourceEnum getBusinessSourceByCode(byte code) {
		for (BusinessSourceEnum businessSource : values()) {
			if (code == businessSource.code) {
				return businessSource;
			}
		}
		return null;
	}
}
